//
//  AXHomeNzscCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/22.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXHomeNzscFirstCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "AXHomeNzscFirstCollectionCell.h"

@interface AXHomeNzscFirstCell ()<UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>
//CollectionView数据
@property (nonatomic, strong) NSArray<NSString *> *imageNames;
@property (nonatomic, strong) NSArray<NSString *> *titles;

@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic , assign) NSInteger index;
@end

@implementation AXHomeNzscFirstCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initDatas];
        [self creatView];
        [self setlayout];
    }
    return self;
}

- (void)initDatas {
    
    self.imageNames = @[@"nzsc_nzfl",@"nzsc_nztj",@"nzsc_fwwd",@"nzsc_yxsy",@"nzsc_phb"];
    self.titles = @[@"农资分类", @"农资推荐", @"服务网点", @"药效实验",@"排行榜"];
    
    
}

- (void)creatView {
    
    /** collectionView */
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH)/5.0, 90);
    /** 最小行间距 */
    flowLayout.minimumLineSpacing = 10;
    /** 最小列间距 */
    flowLayout.minimumInteritemSpacing = 0;
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, 90) collectionViewLayout:flowLayout];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [self.collectionView registerClass:[AXHomeNzscFirstCollectionCell class] forCellWithReuseIdentifier:[AXHomeNzscFirstCollectionCell reuseID]];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.contentView addSubview:self.collectionView];
}

- (void)setlayout {
    
}

#pragma mark - Collection View Data Source
/** 定义展示的section的个数 */

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    
    return 1;
}
/** 定义展示的collectionCell的个数 */
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    
    return 5;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    AXHomeNzscFirstCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[AXHomeNzscFirstCollectionCell reuseID] forIndexPath:indexPath];
    cell.menuImageView.image = [UIImage imageNamed:self.imageNames[indexPath.row]];
    cell.nameLabel.text = self.titles[indexPath.row];
    
    
    return cell;
}

#pragma mark - collectionViewDelegateFlowLayout

/** UICollectionView被选中时的方法 */

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
    
    if (self.tapButtonClickedBlock) {
        self.tapButtonClickedBlock(indexPath.row);
    }
    
    
}


#pragma mark - Setter & Getter

//- (NSMutableArray<ZXResourceModel *> *)modelsArray {
//    if (!_modelsArray) {
//        _modelsArray = [NSMutableArray<ZXResourceModel *> array];
//    }
//    return _modelsArray;
//}





@end
